class Async {
  validateForm(form) {
    return new Promise((resolve, reject) => {
      form
        .validate()
        .then(() => {
          resolve(true);
        })
        .catch(errors => {
          console.log('校验失败');
        });
    });
  }
  delay(time) {
    return new Promise((resolve, reject) => {
      let uid = setTimeout(() => {
        clearTimeout(uid);
        resolve();
      }, time);
    });
  }
  isValidPassword(password, minLength = 8) {
    const specialChars = '!"#$%&\'()*+,-./:;<=>?@$$^_`{|}~';
    const regexStr = `^(?:(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)|(?=.*[a-z])(?=.*[A-Z])(?=.*[${specialChars}])|(?=.*[a-z])(?=.*\\d)(?=.*[${specialChars}])|(?=.*[A-Z])(?=.*\\d)(?=.*[${specialChars}])).{${minLength},}$`;
    const regex = new RegExp(regexStr);
    return regex.test(password);
  }
}
export default new Async();
